package com.dsteiner.gwt.cafeteriasophia.client.event;

import java.util.List;

import com.dsteiner.gwt.cafeteriasophia.client.domain.Change;
import com.dsteiner.gwt.cafeteriasophia.client.domain.Product;
import com.dsteiner.gwt.cafeteriasophia.client.domain.ShiftChange;
import com.dsteiner.gwt.cafeteriasophia.client.model.ProductModel;
import com.dsteiner.widgets.client.event.Event;

public class ChangesEvent implements Event {

	private final List<Change> changes;
	private final List<ProductModel> productModels;
	private final double totalValueChange;
	private ShiftChange shiftChange;

	public ChangesEvent(List<Change> changes, List<ProductModel> productModels, double totalValueChange, ShiftChange shiftChange) {
		this.changes = changes;
		this.productModels = productModels;
		this.totalValueChange = totalValueChange;
		this.shiftChange = shiftChange;
	}
	
	public List<Change> getChanges() {
		return changes;
	}
	public List<ProductModel> getProductModels() {
		return productModels;
	}
	public double getTotalValueChange() {
		return totalValueChange;
	}

	public Change getChange(Product product) {
		if(changes == null)
			return null;
		
		for (Change change : changes) {
			if(change.getProduct().equals(product))
				return change;
		}
		return null;
	}

	public ShiftChange getShiftChange() {
		return shiftChange;
	}
	public void setShiftChange(ShiftChange shiftChange) {
		this.shiftChange = shiftChange;
	}
}
